package HanShuFangFa;

import java.util.Arrays;
import java.util.Scanner;

public class SanGuoHero_pro {

    public static void menu(){
        System.out.println("请输入1：查询 所有 三国英雄角色");
        System.out.println("请输入2：按照 姓氏 查询三国英雄角色");
        System.out.println("请输入3：按照 关键词 查询三国英雄角色");
        System.out.println("请输入4：退出系统");
    }

    public static void findByFirstName(String [] arrs_sanguo, Scanner scanner) {
        System.out.println("请输入 英雄的姓氏：");
        String name1 =scanner.next();
        for(String name1For : arrs_sanguo){
            if(name1For.startsWith(name1)){
                System.out.println(name1For);
            }
        }
    }

    public static void findByKeyWord(String [] arrs_sanguo, Scanner scanner){
        System.out.println("请输入 英雄名称的关键词");
        String name2 = scanner.next();
        for (String name2For : arrs_sanguo){
            if (name2For.contains(name2)){
                System.out.println(name2For);
            }
        }
    }



        public static void main(String[] args) {
//        三国群英系统
            String[] arrs_sanguo = {"曹操","刘备","孙权","诸葛亮","周瑜","赵云","关羽","张飞","司马懿",
                    "黄忠","马超", "吕布","庞统","姜维","郭嘉","贾诩","鲁肃","吕蒙"};
            System.out.println("主人泥嚎，欢迎进入三国群英系统！！");

            while(true){
                menu();
                Scanner scanner = new Scanner(System.in);
                int in = scanner.nextInt();

                switch(in){
                    case 1:
                        System.out.println(Arrays.toString(arrs_sanguo));
                        break;
                    case 2:
                        findByFirstName(arrs_sanguo, scanner);
                        break;
                    case 3:
                        findByKeyWord(arrs_sanguo, scanner);
                        break;
                    case 4:
                        System.exit(0);
                }
            }
        }
    }
